package openadmin.model.person;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.persistence.ManyToOne;
import openadmin.dao.Base;
import javax.persistence.JoinColumn;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

@Entity
@Table(name = "communication", schema = "person", uniqueConstraints = @UniqueConstraint(columnNames={"typecommunication","person"}))
public class Communication implements Base, java.io.Serializable{

	/** attribute that contains the identifier*/
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)	
	private Integer id;

	/** attribute that contains the description, unique value*/
	@Length(max = 40)
	@NotNull
	private String description;

	/** attribute that contains the relationship with Type Communication*/
	@ManyToOne
	@JoinColumn(name = "typecommunication", nullable= false)
	private TypeCommunication typecommunication;	

	/** attribute that contains the relationship with Person*/
	@ManyToOne
	@JoinColumn(name = "person", nullable= false)
	private Person person;

	/** Transient attribute that means that the system should make a log on any JPA operation of this class*/
	@Transient
	boolean debuglog = true;
	
	/** Transient attribute that means that the system should make a historic on any JPA operation of this class*/
	@Transient
	boolean historiclog = false;
	
	public Communication() {
		super();
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public TypeCommunication getTypecommunication() {
		return typecommunication;
	}

	public void setTypecommunication(TypeCommunication typecommunication) {
		this.typecommunication = typecommunication;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}
	
	public boolean getDebugLog() {
		
		return debuglog;
	}

	public void setDebuglog(boolean debuglog) {
		this.debuglog = debuglog;
	}
	
	public boolean getHistoricLog() {
		return historiclog;
	}

	public void setHistoricLog(boolean historiclog) {
		this.historiclog = historiclog;
	}

	@Override
	public String toString(){
		 
		 return description;
	}
}
